#pragma once
#include "stdafx.h"
#define EXCEPTION(v) throw BasicException( v,__FILE__,__FUNCTION__,__LINE__);
#define FILE_EXCEPTION(f,s) throw FileException(f,s,__FILE__,__FUNCTION__,__LINE__);
#define DX11_EXCEPTION(err,info) throw DX11Exception(err,info,__FILE__,__FUNCTION__,__LINE__);
#define ERROR_MESSAGE(hr) DXGetErrorDescription(hr)
#define CHECK_FAILED(hr) \
	if(FAILED(hr)) \
	{ \
	DX11_EXCEPTION("DeviceClass",ERROR_MESSAGE(hr));\
	}


#define PRINT_ERROR(e) MessageBox(NULL,e.what(),"Error",MB_OK),exit(-1);
#define PRINT_BOOST_ERROR(e) { \
	stringstream str; \
	str<<"File:"<<__FILE__<<endl; \
	str<<"Function:"<<__FUNCTION__<<endl; \
	str<<"Line:"<<__LINE__<<endl; \
	str<<e.what()<<endl; \
	MessageBox(NULL,str.str().c_str(),"Boost Error",MB_OK);\
	exit(-1); \
}

class BasicException : public std::exception 
{
public:
	BasicException(string ,string ,string , int );
	~BasicException();
	virtual void Description();
	void Dump();
	virtual const char * what() const;
protected:
	int m_line;
	string m_errorMessage;
	string m_output;
	string m_function;
	string m_file;
};

class DX11Exception : public BasicException
{
public:
	DX11Exception(string,string,string,string,int);
	~DX11Exception();
	virtual void Description();
protected:
	string m_info;
};

enum FILE_ERROR_FORMAT
{
	FAILED_OPEN,
	FAILED_READ,
	FAILED_WRITE
};

class FileException :public BasicException
{
public:

	FileException(string, FILE_ERROR_FORMAT, string, string, int);
	~FileException();
	virtual void Description();
protected:
	string m_info;
	FILE_ERROR_FORMAT m_format;
};
